public class Login {
    private String userName = "admin";
    private String passWord = "123456";
    public void loginInfo(String userName, String passWord) throws UserNameException{
        if(!this.userName.equals(userName)) {
            throw new UserNameException(userName+"用户名错误");
/*            System.out.println("用户名错误");
            return;*/
        }
        if(!this.passWord.equals(passWord)) {
            throw new PasswordException(passWord+"密码错误");
/*            System.out.println("密码错误");
            return;*/
        }
        System.out.println("登陆成功");
    }

    public static void main(String[] args) throws UserNameException{
        Login login = new Login();
        try {
            login.loginInfo("admin","23456");
        }catch(UserNameException e) {
            e.printStackTrace();
        }

    }
}
